package net.csdn.business.discuss.common.constant;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @ClassName RedisConstants
 * @Description 缓存配置类
 * @Author zhangyl
 * @Date 2023/8/2 18:18
 */
public class RedisConstants {
    /**
     * key 过期时间配置 单位 秒
     */
    private static final Map<String, Integer> KEY_TO_TIMEOUT = Maps.newHashMap();

    public static final String SEP = "::";
    public static final String UNDERLINE = "_";
    public static final String STRIKE = "-";

    public static final String PROJECT = "pro";

    public static final String DISCUSS_LIST_PAGE = "dis:list:p:";
    /**
     * 我创建的讨论列表缓存
     */
    public static final String DISCUSS_MY_LIST_PAGE = "dis:list:my:p:";
    /**
     * 我参与的讨论列表缓存
     */
    public static final String DISCUSS_JOIN_LIST_PAGE = "dis:list:join:p:";
    public static final String DISCUSS_CATEGORY_ALL_LIST = "dis:cate:all:list:";
    /**
     * 讨论最近30天采纳回复数排行
     */
    public static final String DISCUSS_ANSWER_SORT_30_LIST = "dis:ans:sort_30:list:";

    // 初始化map
    static {
        KEY_TO_TIMEOUT.put(PROJECT, 60);
        KEY_TO_TIMEOUT.put(DISCUSS_LIST_PAGE, 5*60);
        KEY_TO_TIMEOUT.put(DISCUSS_CATEGORY_ALL_LIST, 12*60*60);
        KEY_TO_TIMEOUT.put(DISCUSS_ANSWER_SORT_30_LIST, 5*60);
    }

    public static Map<String, Integer> getKeyToTimeout() {
        return KEY_TO_TIMEOUT;
    }
}